<template>
    <div>
     <h1>门店信息修改</h1>
     <table class="table">
        <thead>
            <tr>
                <td>门店名称</td>
                <td>
                   <input type="text" v-model="data.name">
                </td>
            </tr>
             <tr>
                <td>门店图片</td>
                <td>
                      <input type="file" @change="Upload">
                      <img :src="'https://localhost:7162'+data.img" style="height: 60px;width: 60px;">

                </td>
            </tr>
             <tr>
                <td>门店电话</td>
                <td>
                     <input type="text" v-model="data.phone">
                </td>
            </tr>
             <tr>
                <td>门店地址</td>
                <td>
                     <input type="text" v-model="data.address">
                </td>
            </tr>
             <tr>
                <td>门店状态</td>
                <td>
                    <input type="radio" name="start" id="" v-model="data.start" value="1">开店
                     <input type="radio" name="start" id="" v-model="data.start" value="2">闭店
                </td>
            </tr>
             <tr>
              
                <td colspan="2">
                    <input type="button" value="修改" @click="Add">
                </td>
            </tr>
        </thead>
     </table>
    </div>
</template>

<script setup lang="ts">
import {ref,onMounted} from "vue"
import axios from "axios";
import { useRouter,useRoute } from "vue-router";
const router=useRouter()
const route=useRoute()
onMounted(()=>{
    Fantian()
})
const Fantian=()=>{
  var x=route.query.id
  axios.get("https://localhost:7162/api/Member/Fantian",{params:{id:x}}).then(res=>{
    data.value=res.data
  })
}
const data=ref({
     "isDelete": true,
  "createId": 0,
  "createTime": "2025-06-16T08:36:58.208Z",
  "updateId": 0,
  "updateTime": "2025-06-16T08:36:58.208Z",
  "deleteId": 0,
  "deleteTime": "2025-06-16T08:36:58.208Z",
  "memberId": 0,
  "name": "",
  "img": "",
  "phone": "",
  "address": "",
  "start": 0
})
const Add=()=>{
    axios.put("https://localhost:7162/api/Member/UptMember",data.value).then(res=>{
     
        if(res.data>0){
            alert('修改成功');
            router.push("/ShowMemberView");
        }
        else{
            alert('修改失败');
        }
    })
}
const Upload=(e:any)=>{
     var f=e.target.files[0]
     var fd=new FormData()
     fd.append("file",f)
     axios.post("https://localhost:7162/api/UpLoad/upload",fd).then(res=>{
        data.value.img=res.data
     })
}
</script>

<style scoped>

</style>